// store/modules/payment.js
import axios from 'axios';

export default {
    namespaced: true,
    state: {
        error: null,
    },
    mutations: {
        SET_ERROR(state, error) {
            state.error = error;
        },
    },
    actions: {
        async notifyCancellation({ commit }) {
            try {
                await axios.post('order/api/payment/cancel');
            } catch (error) {
                console.error('Error notifying payment cancellation:', error);
                commit('SET_ERROR', '通知取消支付时出错，但不影响您的操作。');
            }
        },
    },
    getters: {
        getError: state => state.error,
    },
};
